package com.cd.form.jpa.domian;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import java.io.Serializable;
import java.util.Objects;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Embeddable
public class FormAuthId implements Serializable {

    private static final long serialVersionUID = 1L;

    @Column(name = "form_id")
    private Long formId;

    @Column(name = "user_id")
    private Long userId;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof FormAuthId)) return false;
        FormAuthId that = (FormAuthId) o;
        return Objects.equals(formId, that.formId) &&
               Objects.equals(userId, that.userId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(formId, userId);
    }
}